// pages/home/home.js
Page({
  data: {
    currentCity: '贵阳市',
    weatherData: {
      temperature: '26',
      weather: '晴',
      highTemp: '28',
      indices: [
        { name: '负氧离子', value: '92', color: 'blue' },
        { name: '徒步强度', value: '适宜', color: 'green' },
        { name: '紫外线', value: '中等', color: 'orange' },
        { name: '体感舒适度', value: '舒适', color: 'purple' }
      ]
    },
    recommendations: [
      {
        id: 1,
        name: '荔波小七孔',
        rating: 4.9,
        tags: ['森林负氧', '情绪调节'],
        description: '拥有"地球腰带上的绿宝石"美誉，森林覆盖率高达97%，负氧离子含量极高。',
        price: 138,
        image: 'https://images.unsplash.com/photo-1529822438134-3adce6a81a09'
      },
      {
        id: 2,
        name: '平坝樱花园',
        rating: 4.8,
        tags: ['舒缓身心', '缓解压力'],
        description: '亚洲最大的樱花园，拥有10万余株樱花树，春季盛开，漫天樱花如云似霞。',
        price: 69,
        image: 'https://images.unsplash.com/photo-1567331711402-509c12c41959'
      }
    ]
  },

  onLoad: function () {
    // 页面加载时可以从服务器获取数据
    // this.getWeatherData();
    // this.getRecommendations();
  },

  onShow: function () {
    // 页面显示时的逻辑
  },

  // 导航到四季页面
  navigateToSeasons: function(e) {
    const season = e.currentTarget.dataset.season;
    wx.navigateTo({
      url: `/pages/seasons/seasons?season=${season}`
    });
  },

  // 通用导航函数
  navigateTo: function(e) {
    const url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url
    });
  },

  // 搜索点击事件
  onSearch: function() {
    wx.showToast({
      title: '搜索功能开发中',
      icon: 'none'
    });
  },

  // 获取天气数据
  getWeatherData: function() {
    // 这里可以实现从API获取实时天气数据
    wx.showLoading({
      title: '加载中',
    });
    
    // 模拟API请求
    setTimeout(() => {
      this.setData({
        weatherData: {
          temperature: '26',
          weather: '晴',
          highTemp: '28',
          indices: [
            { name: '负氧离子', value: '92', color: 'blue' },
            { name: '徒步强度', value: '适宜', color: 'green' },
            { name: '紫外线', value: '中等', color: 'orange' },
            { name: '体感舒适度', value: '舒适', color: 'purple' }
          ]
        }
      });
      wx.hideLoading();
    }, 500);
  },

  // 获取推荐列表
  getRecommendations: function() {
    // 这里可以实现从API获取推荐景点数据
    wx.showLoading({
      title: '加载中',
    });
    
    // 模拟API请求
    setTimeout(() => {
      this.setData({
        recommendations: [
          {
            id: 1,
            name: '荔波小七孔',
            rating: 4.9,
            tags: ['森林负氧', '情绪调节'],
            description: '拥有"地球腰带上的绿宝石"美誉，森林覆盖率高达97%，负氧离子含量极高。',
            price: 138,
            image: 'https://images.unsplash.com/photo-1529822438134-3adce6a81a09'
          },
          {
            id: 2,
            name: '平坝樱花园',
            rating: 4.8,
            tags: ['舒缓身心', '缓解压力'],
            description: '亚洲最大的樱花园，拥有10万余株樱花树，春季盛开，漫天樱花如云似霞。',
            price: 69,
            image: 'https://images.unsplash.com/photo-1567331711402-509c12c41959'
          }
        ]
      });
      wx.hideLoading();
    }, 500);
  }
}) 